package com.aiyun.dubbo.web;


import com.aiyun.dubbo.service.HelloService;
import org.apache.dubbo.config.annotation.Reference;

import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
@RefreshScope
public class HelloResource {

	@Reference
	HelloService helloService;

	@GetMapping("/hello")
	public ResponseEntity<String> sayHello(String name) {
		System.out.println("Hello");
		String s = helloService.sayHello(name);
		return ResponseEntity.ok(s);
	}


	@GetMapping("/time")
	public ResponseEntity<String> getCurrentTime() {
		String currentTime = helloService.getCurrentTime();
		return ResponseEntity.ok(currentTime);
	}
}
